package com.czxy.advert.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.czxy.domain.TbAdvert;
import com.czxy.advert.mapper.AdvertMapper;
import com.czxy.advert.service.AdvertService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.czxy.vo.AdvertVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 广告(轮播图模块) 服务实现类
 * </p>
 *
 * @author xuewen
 * @since 2022-01-23
 */
@Service
public class AdvertServiceImpl extends ServiceImpl<AdvertMapper, TbAdvert> implements AdvertService {

    @Override
    public Page<TbAdvert> condition(Integer current, Integer pageSize, Integer isShow) {
        QueryWrapper queryWrapper = new QueryWrapper();
        if (isShow!=2){
            queryWrapper.eq("is_show",isShow);
        }
        Page page = new Page(current,pageSize);
        this.baseMapper.selectPage(page,queryWrapper);
        return page;
    }

    @Override
    public Page<TbAdvert> adminFindAll(AdvertVo advertVo) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq(StringUtils.isNotBlank(advertVo.getIsShow()),"is_show",advertVo.getIsShow());
        Page page = new Page(advertVo.getCurrent(),advertVo.getSize());
        this.baseMapper.selectPage(page,queryWrapper);
        return page;
    }
}
